<?php
/*
+ --------------------------------------------------- +
|  Ineo Article Manager - Version 2.x
|  Copyright 2006-2007, Dan Cryer and William McGann
+ --------------------------------------------------- +

Ineo Article Manager is free software; you can redistribute it and/or modify
it under the terms of version 3 of the GNU General Public License as published by
the Free Software Foundation.

Ineo Article Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Ineo; see the file License.txt.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

*/

/**
* Ineo - Libraries - Events Handler
*  
* This library is used for events that are called in multiple places throughout the system.
* Such as article creation, etc.
*
* @package		Ineo
* @subpackage   Libraries
* @author		Dan Cryer & William McGann
* @copyright	Dan Cryer & William McGann
* @version		1.1
*/

class ineo_lib_events
{
	/**
	* Set up variables:
	*/
	var $core     = null;
	var $ipsclass = null;
	
	/**
	* Constructor:
	*/
	function ineo_lib_events( &$ineo )
	{
		$this->core     =& $ineo;
		$this->ipsclass =& $ineo->ipsclass;
	}
	
	/**
	* On Article Creation Complete
	* This is called when article creation is complete. If moderation queueing is disabled,
	* it will be called at creation time. If it is enabled, it will be called at approval time.
	*/
	function article_create_complete( $article_id , $category_id )
	{
		// If we're auto-creating discussion topics, then auto-create it now!
		// Oh, but only if that feature is not disabled!!
		if( $this->ipsclass->vars['ineo_dtopics'] and $this->ipsclass->vars['ineo_dtopics_auto'] )
		{
			$this->core->libs['global']->create_discussion_topic($article_id);
		}
		
		// If the categories library is not loaded, do so now:
		if( !is_object($this->core->categories) )
		{
			$this->core->load_library('categories');
		}
		
		// Update the article count for the article's category:
		$this->core->categories->update_article_count( $article['article_cat_id'] );
		
		// Alert users that have the category in their watchlist:
		$this->lib_global->watchlist_alert( $article['article_cat_id'], 2, $article_id );
	}
}

?>